﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJASPX.Framwork.UI;
using log4net;
using FJASPX.Service;
using NHibernate.Criterion;
using PlugNT.Common;

namespace PlugNT.Cms.Web.Member
{
    public partial class ProductClass : PageBase
    {
        private static readonly ILog logger = LogManager.GetLogger(typeof(Product));

        public IProductClassService iProductClassService { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            Delete();
            Bind();
        }
        private void Bind()
        {
            try
            {
                long totalCount = 0;
                ICriterion criterion = Expression.Eq("UserName", this.Page.User.Identity.Name);
                List<Order> orders = new List<Order>();
                orders.Add(new Order("TimeStamp", false));
                this.entityTable.DataSource = iProductClassService.PagedQuery(criterion, orders, 0, PageSize, out totalCount);
                this.entityTable.DataBind();
            }
            catch (Exception ee)
            {
                Response.Write(ee.Message.ToString());
            }
        }
        private void Delete()
        {
            if (Request.QueryString["action"] != null && "delete".Equals(Request.QueryString["action"].ToString()))
            {
                int entityId = Int32.Parse(Request.QueryString["entityId"]);
                try
                {
                    iProductClassService.DeleteById(entityId);
                    JScript.Alert("删除成功！");
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                }
            }
        }
    }
}